<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>table模块快速使用</title>
  <link rel="stylesheet" href="./layui/css/layui.css" media="all">
</head>
<body>
 
<table id="demo" lay-filter="test"></table>
 
<script src="./layui/layui.js"></script>
<script src="./js/controller.js"></script>
<script>
layui.use('table', function(){
  var table = layui.table;
  var token = null;
  if (localStorage.getItem(tokenName) != null) {
    token = localStorage.getItem(tokenName).toString();
  }
  //第一个实例
  table.render({
    elem: '#demo',
    height: 650,
    url: ojurl + "/problem/infoList", //数据接口
    page: true, //开启分页
    limit: 15,
    headers: {"token" : token},
    parseData: function(res){ //res 即为原始返回的数据
      console.log(res);
      return {
        "code": res.code, //解析接口状态
        "msg": res.message, //解析提示文本
        "count": res.data.count, //解析数据长度
        "data": res.data.list //解析数据列表
      };
    },
    response: {
      statusCode: 200 //规定成功的状态码，默认：0
    },
    cols: [[ //表头
      {field: 'problemId', title: 'ID', sort: true, fixed: 'left'},
      {field: 'title', title: '标题'},
      {field: 'source', title: '来源', sort: true},
      {field: 'author', title: '作者'},
      {field: 'docType', title: '题面方式', width: 90},
      {field: 'timeLimit', title: '时限(S)', width: 90},
      {field: 'timeLimitSpc', title: '特别时限(S)', width: 110},
      {field: 'memoryLimit', title: '内存限制(M)', width: 110},
      {field: 'dataVersion', title: '评测数据版本', width: 120},
      {field: 'accepts', title: '通过数', width: 90},
      {field: 'ratio', title: '通过率', width: 90},
      {field: 'isSpj', title: '是否特判', width: 90},
      {field: 'addTime', title: '题目添加时间'},
      {field: 'judgeFiles', title: '评测数据组数', width: 120},
      {field: 'isShow', title: '是否公开', width: 90}
    ]]
  });
  
});
</script>
</body>
</html>